import { ElNotification, ElMessage,ElMessageBox,ElLoading } from 'element-plus'


// 普通信息提示
export function infoMsg(msgInfo){
    ElMessage({
        type: 'info',
        showClose: true,
        dangerouslyUseHTMLString: true,
        message: msgInfo,
    })
}

// 成功提示
export function succesMsg(msgInfo){
    ElMessage({
        type: 'success',
        showClose: true,
        dangerouslyUseHTMLString: true,
        message: msgInfo,
    })
}

// 错误提示
export function errorMsg(msgInfo){
    ElMessage({
        type: 'error',
        showClose: true,
        dangerouslyUseHTMLString: true,
        message: msgInfo,
    })
}

// 警告提示
export function warnMsg(msgInfo){
    ElMessage({
        type: 'warning',
        showClose: true,
        dangerouslyUseHTMLString: true,
        message: msgInfo,
    })
}

// 带一个确定按钮或是按钮的alertBox
export function alertBox(msg,btnName,type) {
    let confirmName = btnName == '确定'? '确定' : '是'
    return ElMessageBox.alert(msg, '提示',{
        type: type,
        confirmButtonText: confirmName,
        dangerouslyUseHTMLString: true
    });
    // 使用实例
    // alertBox('确认删除该标签吗？','确定',null).then(res => {
    //     console.log("确定：", res)
    // })
}

// 带确定取消按钮或者是否按钮的弹出提示框
export function confirmBox(msg,btnName,type) {
    let confirmName = btnName == '确定'? '确定' : '是'
    let cancelsName = btnName == '确定'? '取消' : '否'
    return ElMessageBox.confirm(msg,'提示', {
        type: type,
        confirmButtonText: confirmName,
        cancelButtonText: cancelsName,
        closeOnClickModal: false,
        closeOnPressEscape: false,
        dangerouslyUseHTMLString: true
    })
    // 使用实例
    // confirmBox('确认删除该标签吗？','确定',null).then(res => {
    //     console.log("确定：", res)
    // }).catch(res => {
    //     console.log("取消关闭：", res)
    // })
}

// Notification 从屏幕四角中的Top Right弹出
export function topright(title,message) {
    ElNotification({
        title: title,
        message: message,
    })
}

// Notification 从屏幕四角中的Bottom Right弹出
export function bottomright(title,message) {
    ElNotification({
        title: title,
        message: message,
        position: 'bottom-right',
    })
}

// Notification 从屏幕四角中的Bottom Left弹出
export function bottomleft(title,message) {
    ElNotification({
        title: title,
        message: message,
        position: 'bottom-left',
    })
}

// Notification 从屏幕四角中的Top Left弹出
export function topleft(title,message) {
    ElNotification({
        title: title,
        message: message,
        position: 'top-left',
    })
}

let loadingInstance;
// loading加载 全屏锁屏
export function showLoading() {
    loadingInstance = ElLoading.service({
        lock: true,
        text: "数据加载中，请稍等！",
        background: 'rgba(0, 0, 0, 0.7)'
    });
}

// loading加载 去除全屏锁屏
export function hideLoading() {
    loadingInstance.close();
}
